package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Classresourse;
import com.ruoyi.system.service.IClassresourseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课程资源管理Controller
 * 
 * @author ruoyi
 * @date 2024-05-30
 */
@RestController
@RequestMapping("/system/classresourse")
public class ClassresourseController extends BaseController
{
    @Autowired
    private IClassresourseService classresourseService;

    /**
     * 查询课程资源管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:classresourse:list')")
    @GetMapping("/list")
    public TableDataInfo list(Classresourse classresourse)
    {
        startPage();
        List<Classresourse> list = classresourseService.selectClassresourseList(classresourse);
        return getDataTable(list);
    }

    /**
     * 导出课程资源管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:classresourse:export')")
    @Log(title = "课程资源管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Classresourse classresourse)
    {
        List<Classresourse> list = classresourseService.selectClassresourseList(classresourse);
        ExcelUtil<Classresourse> util = new ExcelUtil<Classresourse>(Classresourse.class);
        util.exportExcel(response, list, "课程资源管理数据");
    }

    /**
     * 获取课程资源管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:classresourse:query')")
    @GetMapping(value = "/{classresourseNumber}")
    public AjaxResult getInfo(@PathVariable("classresourseNumber") Integer classresourseNumber)
    {
        return success(classresourseService.selectClassresourseByClassresourseNumber(classresourseNumber));
    }

    /**
     * 新增课程资源管理
     */
    @PreAuthorize("@ss.hasPermi('system:classresourse:add')")
    @Log(title = "课程资源管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Classresourse classresourse)
    {
        return toAjax(classresourseService.insertClassresourse(classresourse));
    }

    /**
     * 修改课程资源管理
     */
    @PreAuthorize("@ss.hasPermi('system:classresourse:edit')")
    @Log(title = "课程资源管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Classresourse classresourse)
    {
        return toAjax(classresourseService.updateClassresourse(classresourse));
    }

    /**
     * 删除课程资源管理
     */
    @PreAuthorize("@ss.hasPermi('system:classresourse:remove')")
    @Log(title = "课程资源管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{classresourseNumbers}")
    public AjaxResult remove(@PathVariable Integer[] classresourseNumbers)
    {
        return toAjax(classresourseService.deleteClassresourseByClassresourseNumbers(classresourseNumbers));
    }
}
